﻿using System;
using Tiens.NotificationHub.Core.Utils;

namespace Tiens.NotificationHub.Core.Extensions
{
    public static class CBCDecryptorExtensions
    {
        public static string DecryptToUserId(this CBCDecryptor decryptor, string ciphertext)
        {
            if (!decryptor.TryDecrypt(ciphertext, out string translation))
                throw new ArgumentException($"无法根据密文解析成用户Id,token =>{ciphertext}", nameof(ciphertext));

            return translation.Substring(0, translation.Length - 14);
        }
    }
}
